<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>DWR TEST</title>
	<script type='text/javascript' src='${pageContext.request.contextPath}/dwr/engine.js'></script>
	<script type='text/javascript' src='${pageContext.request.contextPath}/dwr/interface/Demo.js'></script>
	<script type='text/javascript' src='${pageContext.request.contextPath}/dwr/util.js'></script>
	
	<script type="text/javascript">
	    //此函数中可以调用java类的方法，除了java方法本身的参数外，还要将回调函数名作为参数传给java方法  
		function sayHello() {
	    	var name = dwr.util.getValue("demoName");
			Demo.getHello(name, {
				callback : function(data) {
					dwr.util.setValue("demoReply", data);
				},
				timeout : 5000,
				errorHandler : function(message) {
					alert("Error : " + message);
				}
			});
		}

		function doSomethingWithPerson() {
			var myJSPerson = {
				name : "Fred Bloggs",
				age : 42
			};
			Demo.doSomethingWithPerson(myJSPerson);
		}

		function forward() {
			Demo.getInclude(function(data) {
				dwr.util.setValue("forward", data, {
					escapeHtml : false
				});
			});
		}
	</script>
</head>
<body>
	<table cellpadding="10" border="1" width="100%">
		<tr>
			<td>
				Name: <input type="text" id="demoName"/>
				<input value="Send" type="button" onclick="sayHello()"/>
				Reply: <span id="demoReply"></span>
			</td>
		</tr>
		
		<tr>
			<td>
				<input value="Include Page" type="button" onclick="forward()"/><br/>
				Included Page:
				<div id="forward"></div>
			</td>
		</tr>
		
		<tr>
			<td><a href="${pageContext.request.contextPath}/page/dwr/EditableTable.jsp">Editable Table Demo</a></td>
		</tr>
		
		<tr>
			<td><a href="${pageContext.request.contextPath}/page/dwr/JavascriptChat.jsp">JavaScript Chat Demo</a></td>
		</tr>
		
		<tr>
			<td><a href="${pageContext.request.contextPath}/page/dwr/JavaChat.jsp">Java Chat Demo</a></td>
		</tr>
	</table>
	
</body>
</html>